/**
 * Created by raniys on 4/12/17.
 */

PROD_LIST = ['server-wap', 'server-quote', 'server-node'];
DEVELOP = false;
var util = require('util');

//判断测试生产环境
var fs = require('fs');
var envFilePath = (process.env.HOME || process.env.USERPROFILE) + '/server_name';
if (fs.existsSync(envFilePath)) {
    var data = fs.readFileSync(envFilePath, {flag: 'r+', encoding: 'utf8'});
    for (var i in PROD_LIST) {
        if (PROD_LIST[i] == data) {
            DEVELOP = false;
            break;
        }
    }
}
// console.log('环境: ' + (DEVELOP ? '测试' : '生产'));

//测试环境的地址
HUB_SERVER = "10.0.27.7";
MG_SERVER = "10.0.27.7";
DB_SERVER = '10.0.27.12';

//长链接的地址
WEB_SOCKET_URL = 'http://10.0.27.7:1800';
//http接口地址
WEB_HTTP_URL = 'http://10.0.27.7';
//微盘http接口地址
VPAN_HTTP_URL = 'http://10.0.27.7:8889';
//乐股讲堂HTTP接口地址
LEGEND_HTTP_URL = 'http://10.0.27.7:9010';
//图片URL
FILE_URL = 'http://10.0.27.7:16808/file_src/';
//阿里OSS图片URL
OSS_FILE_URL = 'http://file.zxzb01.com/';
//静态资源URL
STATIC_URL = 'http://10.0.27.82:9000';

if (!DEVELOP) {
    //正式站的地址
    HUB_SERVER = "139.196.252.53";
    MG_SERVER = "139.196.176.19";
    DB_SERVER = '121.43.191.73';

    //长链接的地址
    WEB_SOCKET_URL = 'http://139.196.148.74:1800';
    //http接口地址
    WEB_HTTP_URL = 'https://wapi.shrise.cn';
    //微盘http接口地址
    VPAN_HTTP_URL = 'http://139.196.148.74:8889';
    //乐股讲堂HTTP接口地址
    LEGEND_HTTP_URL = 'https://woaapi.shrise.cn';
    //图片URL
    FILE_URL = 'http://139.196.148.74:16808/file_src/';
    //阿里OSS图片URL
    OSS_FILE_URL = 'http://file.zxzb01.com/';
    //静态资源URL
    STATIC_URL = 'https://static.fc093.com';
}

HUB_ADDRESS_LIST = [{ip: HUB_SERVER, port: 2020}, {ip: HUB_SERVER, port: 2021}];
REDIS_ADDRESS = {ip: (DEVELOP ? '10.0.27.7': '139.196.176.19'), port: 6999, pass: 'fc093'};
MG_ADDRESS = util.format('mongodb://%s/MGSessionDB', MG_SERVER);
DB_ADDRESS = {ip: DB_SERVER, user: 'raniys', pass: (DEVELOP ? 'fc_093': 'fc_093')};

module.exports = {
    DEVELOP: DEVELOP,
    WEB_SOCKET_URL: WEB_SOCKET_URL,
    WEB_HTTP_URL: WEB_HTTP_URL,
    VPAN_HTTP_URL: VPAN_HTTP_URL,
    LEGEND_HTTP_URL: LEGEND_HTTP_URL,
    FILE_URL: FILE_URL,
    OSS_FILE_URL:OSS_FILE_URL,
    STATIC_URL: STATIC_URL,
    HUB_ADDRESS_LIST: HUB_ADDRESS_LIST,
    REDIS_ADDRESS: REDIS_ADDRESS,
    DB_ADDRESS: DB_ADDRESS,
    MG_ADDRESS: MG_ADDRESS
};